package com.wgz.flag.config;

import com.wgz.flag.utils.JwtUtil;
import jakarta.websocket.server.ServerEndpointConfig;
import org.springframework.stereotype.Component;
import jakarta.websocket.HandshakeResponse;
import jakarta.websocket.server.HandshakeRequest;

@Component
public class WebSocketAuthInterceptor extends ServerEndpointConfig.Configurator {
    @Override
    public boolean checkOrigin(String originHeaderValue) {
        // TODO: 实现跨域检查
        return true;
    }

    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
        // TODO: 实现token验证
        String token = request.getParameterMap().get("token").get(0);
        // 验证token
        super.modifyHandshake(sec, request, response);
    }
}